////////////////////////////////////////////////////////////////////////////////

#ifndef _INTERSECTOR_H_
#define _INTERSECTOR_H_

////////////////////////////////////////////////////////////////////////////////

#ifndef _PHYSICALOBJECT_H_
#include "physicalobject.h"
#endif

////////////////////////////////////////////////////////////////////////////////

class CircleCircleIntersector;
class CirclePolygonIntersector;
class PolygonCircleIntersector;

////////////////////////////////////////////////////////////////////////////////


/** Base class for objects intersector, intersects two objects
*
*  @author   Anastasia Karpinska
*  @since    Dec 5th, 2009
*  @updated  Dec 5th, 2009
*/
class Intersector
{
////////////////////////////////////////////////////////////////////////////////

public:

////////////////////////////////////////////////////////////////////////////////


    /** Intersects two objects */
    virtual void Intersect( PhysicalObject& _obj1, PhysicalObject& _obj2 ) = 0;


    /** Returns circles intersector instance */
    static Intersector& GetCircleCircleIntersector();


    /** Returns circle and polygon intersector instance */
    static Intersector& GetCirclePolygonIntersector();


    /** Returns polygon and circle intersector instance */
    static Intersector& GetPolygonCircleIntersector();


    /** Tells the result of last intersection
    (was there any intersection or not?) */
    bool WasIntersection() const;


    /** Returns normal of last intersection */
    const PE::Direction GetNormal() const;


////////////////////////////////////////////////////////////////////////////////

private:

////////////////////////////////////////////////////////////////////////////////


    /** Intersector for two circles */
    static CircleCircleIntersector* m_CircleCircleIntersector;


    /** Intersector for circle and polygon */
    static CirclePolygonIntersector* m_CirclePolygonIntersector;


    /** Intersector for polygon and circle */
    static PolygonCircleIntersector* m_PolygonCircleIntersector;


////////////////////////////////////////////////////////////////////////////////

protected:

////////////////////////////////////////////////////////////////////////////////


    /** The result of last intersection (was there any intersection or not?) */
    bool m_WasIntersection;


    /** Normal for collision */
    PE::Direction m_Normal;


////////////////////////////////////////////////////////////////////////////////

};

////////////////////////////////////////////////////////////////////////////////

#endif
